package com.zkm.pay.controller;

import com.alibaba.fastjson.JSON;
import com.zkm.pay.vo.PayVO;
import com.zkm.user.UserService;
import com.zkm.user.vo.UserVO;
import com.zkm.user.vo.WeChatPayVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/pay")
public class PayController {

    @Value("${java.version}")
    private String javaVersion;

    @Resource
    private UserService userService;

    @PostMapping("/weChat")
    public PayVO weChat(@RequestBody WeChatPayVO weChatPayVO) {
        log.info("Java version: {}", javaVersion);
        UserVO userInfo = userService.info(weChatPayVO);
        log.info("用户信息：{}", JSON.toJSONString(userInfo));
        return new PayVO(200, "success");
    }
}
